


export class PreViewContainer {
    private image: any = new Image()
    private previewContatiner: any = document.createElement('div')
    constructor(url: string) {

        //创建弹出层
        this.previewContatiner.style.position = 'fixed'
        this.previewContatiner.style.top = 0
        this.previewContatiner.style.bottom = 0
        this.previewContatiner.style.left = 0
        this.previewContatiner.style.right = 0
        this.previewContatiner.style.zIndex = 99999
        this.previewContatiner.style.backgroundColor = 'rgba(0,0,0,0.8)'
        this.previewContatiner.style.display = 'flex'
        this.previewContatiner.style.justifyContent = 'center'
        this.previewContatiner.style.alignItems = 'center'
        document.body.appendChild(this.previewContatiner)

        this.image.src = url;
        this.image.style.maxWidth = '90%'
        this.image.style.maxHeight = '90%'
        this.image.style.zIndex = 99999
        this.previewContatiner.appendChild(this.image)
        // //点击弹出层，关闭预览
        // previewContatiner.addEventListener('click', () => {
        //     document.body.removeChild(previewContatiner)
        // })

    }

    close() {
        document.body.removeChild(this.previewContatiner)
    }
}

